﻿using System.Collections.Generic;
using Magiq.Providers.Sql.Support;
using Magiq.Query;
using Magiq.Support;
using MirrorMirror;

namespace Magiq.Providers.Sql
{
    public static class QueryInfoExtensions
    {
        public static IEnumerable<TChild> ToEntitySet<T, TChild>(this QueryInfo<T, TChild> self)
        {
            return self.Item.Get<IEnumerable<TChild>>(self.CollectionExpression.ToPropertyInfo().Name);
        }

        public static bool IsEntitySet<T, TChild>(this QueryInfo<T, TChild> self)
        {
            return self.Compiled.IsEntitySet();
        }
    }
}